
var vm = new Vue({
	el:'#rrapp',
	data:{
		q:{
			username: null
		},
		title:'用户注册',
		user:{
			status:1,
			realName: '',
			username: '',
			password: '',
			email: '',
			password2: '',
			referUserId: null,
			payPassword: ''

		}
	},
	methods: {
		saveOrUpdate: function () {
			if(vm.validator()){
				return ;
			}

			var url = "app/pc/register/do";
			$.ajax({
				type: "POST",
				url: baseURL + url,
				contentType: "application/json",
				data: JSON.stringify(vm.user),
				success: function(r){
					if(r.code === 0){
						alert('操作成功', function(){
							window.location.href= baseURL + "login.html";
						});
					}else{
						alert(r.msg);
					}
				}
			});
		},
        validator: function () {
            if(isBlank(vm.user.username)){
                alert("用户名不能为空");
                return true;
            }

            if(isBlank(vm.user.password)){
                alert("密码不能为空");
                return true;
            }

            if (vm.user.password != vm.user.password2) {
				alert("两次密码输入不一致")
				return true;
            }

            if(isBlank(vm.user.weixin)){
                alert("微信号不能为空");
                return true;
            }

            if(isBlank(vm.user.email)){
                alert("邮箱不能为空");
                return true;
            }

            if(isBlank(vm.user.realName)){
                alert("真实姓名不能为空");
                return true;
            }

            if(isBlank(vm.user.payPassword)){
                alert("支付密码不能为空");
                return true;
            }

            if(!validator.isEmail(vm.user.email)){
                alert("邮箱格式不正确");
                return true;
			}
        }
	}
});